<template>
    <h1>购物车</h1>
    <div>
        <table>
            <thead>
                <tr>
                    <th>编号</th>
                    <th>名称</th>
                    <th>价格</th>
                    <th>数量</th>
                    <th>小计</th>
                </tr>
            </thead>
            <tbody>
                <tr v-for="item in rows" :key="item._id">
                    <td>{{ item._id}}</td>
                    <td>{{ item.name }}</td>
                    <td>{{ item.price}}</td>
                    <td>{{ item.num }}</td>
                    <td>{{ item.num*item.price}}</td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script lang='ts' setup>
import useShopcartStore from '@/store/shopcart';
import {onMounted} from 'vue'
import {storeToRefs} from 'pinia'
const store=useShopcartStore()
const {getShopcartListAsync}=store
const {rows}=storeToRefs(store)
onMounted(()=>{
    //调用网络请求的方法
    getShopcartListAsync()
})
</script>

<style lang='scss' scoped>
</style>